<template>
	<view v-if="data.length !== 0">
		<view class="item" v-for="item in data" :key="item.id">
			<view class="top">
				<view class="left">
					<uni-icons type="person" size="20" color="grey"></uni-icons>
					<text style="margin: 0 10upx;">{{item.shopName}}</text>
					<uni-icons type="right" size="20" color="grey"></uni-icons>
				</view>
				<text style="color: rgb(35,209,208);" v-if='item.shopState == 1'>交易完成</text>
				<text style="color: rgb(35,209,208);" v-else>未交易完</text>
			</view>
			<view class="content">
				<!-- <image :src="item.shopImg" mode="widthFix"></image> -->
				<img :src="item.shopImg" style='width: 25%;' alt="">
				<view class="right">
					<view class="top">
						<text style="width: 70%;">{{item.shopTitle}}</text>
						<text style="width: 25%; font-size: 24upx;overflow: hidden;text-overflow: ellipsis;">￥{{item.shopPrice}}.00</text>
					</view>
					<view class="btnBox">
						<el-button class='btn' v-if='item.shopState == 1'>已卖出</el-button>
						<el-button class='btn' v-else>未卖出</el-button>
					</view>
				</view>
			</view>
		</view>
	</view>
	<view class="itemShow" v-else>
		暂无数据
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: []
			};
		},
		onShow() {
			const userId = getApp().globalData.userId;
			// console.log(userId)
			if (userId) {
				this.$api.getISellUserId(userId).then(res => {
					// console.log(res)
					if(res.code == 200) {
						this.data = res.data
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.item {
		width: 90%;
		height: 20vh;
		margin: 40upx auto;
		box-sizing: border-box;
		padding: 20upx 40upx;
		border-radius: 20upx;
		box-shadow: 0px 0px 18upx rgba(0, 0, 0, 0.1);
		display: flex;
		flex-direction: column;
		    justify-content: space-around;

		.top {
			width: 100%;
			display: flex;
			justify-content: space-between;
			font-size: 26upx;

			.left {
				display: flex;
				align-items: center;
			}
		}

		.content {
			width: 100%;
			font-size: 26upx;
			display: flex;

			image {
				width: 25%;
				margin-right: 20upx;
			}

			.right {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.top {
					display: flex;
				}
			}
			.btnBox{
				display: flex;
				justify-content: flex-end;
				.btn{
					padding: 10upx 40upx;
					font-size: 24upx;
					border-radius: 30upx;
					border-color: rgb(35,209,208);
					color: rgb(35,209,208);
				}
			}
		}
	}
	.itemShow {
		width: 130upx;
		margin: 400upx auto 0;
	}
</style>
